import request from '@/utils/request'

// 查询资讯列表
export function listInformation(query) {
  return request({
    url: '/information/information/list',
    method: 'get',
    params: query
  })
}

// 查询资讯详细
export function getInformation(articleId) {
  return request({
    url: '/information/information/' + articleId,
    method: 'get'
  })
}

// 新增资讯
export function addInformation(data) {
  return request({
    url: '/information/information',
    method: 'post',
    data: data
  })
}

// 修改资讯
export function updateInformation(data) {
  return request({
    url: '/information/information',
    method: 'put',
    data: data
  })
}

// 删除资讯
export function delInformation(articleId) {
  return request({
    url: '/information/information/' + articleId,
    method: 'delete'
  })
}

// 查询栏目列表 - 用户端接口
export function listCategory(query) {
  return request({
    url: '/user/category/list',
    method: 'get',
    params: query
  })
}

// 获取评论列表
export function getCommentList(query) {
  return request({
    url: '/comment/list',
    method: 'get',
    params: query
  })
}

// 点赞文章
export function addLike(articleId) {
  return request({
    url: `/information/information/${articleId}/like`,
    method: 'post'
  })
}

// 取消点赞
export function cancelLike(articleId) {
  return request({
    url: `/information/information/${articleId}/cancelLike`,
    method: 'post'
  })
}

// 上传图片
export function uploadImg(data) {
  return request({
    url: '/common/uploadFile',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}